package org.example.myframework.frame.common.exception;

import lombok.Getter;

/**
 * 业务系统统一异常处理
 */
@Getter
public class BaseException extends RuntimeException{

    private int code;

    private String msg;

    private BaseExceptionType baseExceptionType;

    /*************************************构造参数*********************************************/
    public BaseException(BaseExceptionType exceptionType) {
        this(exceptionType.getCode(), exceptionType.getMsg(), exceptionType.getMsg());
        this.baseExceptionType = exceptionType;
    }

    /*************************************构造方法********************************************/
    public BaseException(int code, String msg, Throwable cause) {
        // RuntimeException的构造方法，传入Throwable
        super(cause.getMessage(), cause);
        this.code = code;
        this.msg = msg;
    }

    public BaseException(int code, String msg, String logMsg) {
        // RuntimeException的构造方法，传入String, 类似于写入日志的异常msg
        super(logMsg);
        this.code = code;
        this.msg = msg;
    }
}
